import PreviewItem from '@/components/preview/document.vue';

const PreviewDocument = {};

// 注册
PreviewDocument.install = function (Vue) {
    const PreviewConstructor = Vue.extend(PreviewItem);
    const instance = new PreviewConstructor();
    instance.$mount(document.createElement("div"));
    document.body.appendChild(instance.$el);

    /**
     * 挂载在vue原型上
     * @param {String} file 文件
     */
    Vue.prototype.$openPreviewDocument = function (file) {
        instance.dialogVisible = true;
        instance.previewUrl = file;
    };
};

export default PreviewDocument;